|
If you can't view the Datasheet, Please click here to try to view without PDF Reader . |
|
Datasheet File OCR Text: |
march 2013 docid022544 rev 3 1/23 AN4018 application note data link communication protocol for the st7580 power line networking soc by vincenzo mormina introduction this document describes the data link communication protocol and the services provided to the application layer. this communication protocol is designed from the st7580 power line modem devices. this firmware is available by software license agreement only: ? http://www.st.com/software_license_agreem ent_liberty_v2 addresses conditions to deliver the firmware in source code form ? http://www.st.com/software_license_agreement_image_v2 addresses conditions to deliver the firmware in binary code form (i.e. .lib, .a, ?) please, ask your local st office for further information. www.st.com
contents AN4018 2/23 docid022544 rev 3 contents 1 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2 firmware architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3 framing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 4 service description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 4.1 system initialization services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 4.1.1 data link initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 4.1.2 plm modem channel frequency configuration . . . . . . . . . . . . . . . . . . . 10 4.2 system configuration services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 4.2.1 plm modem configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 4.2.2 set mac address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 4.2.3 get mac address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 4.3 data link services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 4.3.1 allow join request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 4.3.2 join indication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 4.3.3 data request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 4.3.4 data indication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 4.4 data link security services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 4.4.1 security data request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 4.4.2 security data indication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 4.5 mib management services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 4.5.1 mib reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 4.5.2 mib writing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 4.5.3 mib erasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 4.5.4 mib parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 appendix a join procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 appendix b the stm32fx family modem configuration parameter description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 docid022544 rev 3 3/23 AN4018 contents appendix c example to configure the communi cation protocol . . . . . . . . . . . . 19 c.1 configure the stm32fx family serial layer . . . . . . . . . . . . . . . . . . . . . . . . 19 c.2 configure and run the data link layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 appendix d security servic e use and configuration. . . . . . . . . . . . . . . . . . . . . . 21 d.1 how to use the security service. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 d.2 example of mib modem configuration to use the security service . . . . . . 21 5 references . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 6 revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 overview AN4018 4/23 docid022544 rev 3 1 overview the st7580 data link communication protocol provides the services to build and manage a ?master multi-slave? power line network. two different modes are described in this document: ? master multi-slave mode: ? in a master-multi-slave network, one node, and only one node, must be configured as a ?master? while the other nodes must be configured as ?slaves?. each slave needs a join procedure with the master before starting communication; appendix a describes the join procedure. ? simple node mode: ? in simple node mode all the nodes must be configured as ?master?; in this case the nodes do not need a join procedure and they can all communicate with any other node. the protocol has been specified for the stm32fx family microcontroller. it utilizes a serial communication (uart) with the st7580 power line device. docid022544 rev 3 5/23 AN4018 firmware architecture 2 firmware architecture figure 1 shows the firmware architecture: figure 1. firmware architecture the physical layer of the st7580 provides a basic mac service through a serial communication interface. ? bsp layer: ? the ?bsp? layer manages the communication interfaces from the physical layer (st7580) and the data link layer. moreover, this manages the anti-collision repeating message. ? data link layer: ? the ?data link? layer manages the framing sent and received, and the power line modem configuration. ? service layer: ? the ?service? layer provides the data link services to the application layer; it allows messages and commands to be sent and received. ? application layer: ? the ?application? layer can be customized by the user; in this section the user must design the application to create, manage and maintain the network. $ 0 y $ s s o l f d w l r q 6 h u y l f h ' d w d o l q n % 6 3 3 k \ v l f d o 6 7 6 7 0 firmware architecture AN4018 6/23 docid022544 rev 3 figure 2 shows the firmware components and their files: figure 2. firmware components and files $ 0 y 6 h u y l f h ' d w d o l q n % 6 3 g o b v h u y l f h v f g o b v h u y l f h v k g o b p j w f g o b p j w k v w b v w p b e v s f v w b v w p b e v s k docid022544 rev 3 7/23 AN4018 framing 3 framing the communication modulation is an x-psk, and the physical frame is the typical psk frame, shown in figure 3 . figure 3. psk frame where: ? preamble length: 32 bits ? unique word: 16 bits ? mode: 8 bits ? p_sdu length: 8 bits ? p_sdu: max. 255 bytes the p_sdu contains the data link frame which has the structure shown in figure 4 . figure 4. data link frame where: ? ?type? defines the type of frame, which can be: ?allowjoin ? joinreq ?joinack framing AN4018 8/23 docid022544 rev 3 ? leave (not used in this protocol release) ? leaveack (not used in this protocol release) ?data ? ?source uid? and ?destination uid? are the sender and receiver mac address ? ?source level? (not used in this protocol release) ? ?mac payload? is the data ? ?crc? depends on the st7580, for more details see the st7580 datasheet. docid022544 rev 3 9/23 AN4018 service description 4 service description 4.1 system initialization services these services provide functions to initialize the data link layer, to configure and manage the modulation frequency of the power line modem. 4.1.1 data link initialization void dl_init(u8 dltype) description: this function initializes the data link layer, with default parameters; the default parameters are: ? frequency: 86000 hz, 72000 hz ? rx mode: high channel only ? rx h/l channel modulation: all psk modulation ? current control: enabled ? gain: 21 ? zero crossing delay: 0 ? psk preamble length: 32 bits ? fsk baud rate: 2400 bps ? fsk deviation: 1 ? fsk preamble length: 32 bit ? fsk unique word length: 16 bit ? fsk unique word: 0x9b58 input parameters: ? dltype : this parameter defines the data link type, master, slave or simple node; the value accepted is: ?dl_master?, ?dl_slave? or ?dl_simple_node?. output parameters: none. return value: none. note: this function must be called during the system startup. service description AN4018 10/23 docid022544 rev 3 4.1.2 plm modem channel frequency c onfiguration void dl_frequenciesconfig(u32 hchannel, u32 lchannel, freq_type freqtype) description: this service configures the plm st7580 modem frequency channel. the use of this service has a lasting effect, in fact, it changes the default configuration parameters of the frequency channel. if this service is used, the value of the frequency channel is maintained for all successive system activations. input parameters: ? hchannel: frequency channel to configure the high channel, for the accepted value see the st7580 datasheet. ? lchannel: frequency channel to configure the low channel, for the accepted value see the st7580 datasheet. ? freqtype: type of change, valid values ?permanent?, ?not_permanent?. output parameters: none. return value: none. note: this service can be used to change the default frequency channel in the configuration parameters. if the parameter ?freqtype? is ?permanent?, the new modem frequency value is registered in the ram and in the flash memory and this is the new default value. if the parameter ?freqtype? is ?not_permanent?, the new modem frequency value is registered in the ram memory only; at reset this modem frequency value is lost and the system reloads the old default value. 4.2 system configuration services these services provide the functions to configure the power line modem and manage the mac address of the system. 4.2.1 plm modem configuration void dl_modemconfig(mod_configtypedef* modconfparam, conf_type conftype) description: this service is used to configure the modem with a different parameter respect to the default values. this service does not have a lasting effect; the effect of this service is valid while a reset occurs or a new startup is performed. docid022544 rev 3 11/23 AN4018 service description input parameters: ? modconfparam: pointer to ?mod_configtypedef? struct, this includes all modem configuration parameters, this struct, all parameters and the valid parameter values are described in the appendix b . ? conftype: type of change, valid values ?permanent?, ?not_permanent?. output parameters: none. return value: none. note: this service doesn?t substitute dl_init. in fact, the dl_init must be performed at the system initialization layer at all times. if the parameter ? conftype ? is ?permanent?, the new modem configuration value is registered in the ram and in the flash memory and this is the new default value. if the parameter ? confype ? is ?not_permanent?, the new modem configuration value is registered only in the ram memory; at reset this modem configuration value is lost and the system reloads the old default value. 4.2.2 set mac address void dl_addressset(u8* newaddress, ch_addr_type addtype) description: this service is used to set a new mac address. at the first startup, the system gets a uid mac address, this is the uid of the microcontroller.this service can change this address permanently or temporarily. if the service is used ?temporarily? at the reset, the uid mac address is reloaded; if the service is used as ?permanent?, the mac address is changed permanently. input parameters: ? newaddress: pointer to new address, (6-byte array) ? addtype: type of change, valid value ?permanent?, ?not_permanent? ?addtype?. output parameters: none. return value: none. note: if the parameter ?addtype? is ?permanent?, the new address is registered in the ram and in the flash memory, and this is the new default value. if the parameter ?addtype? is ?not_permanent?, the new address is registered in the ram memory only; at reset this address is lost and the system reloads the old default address. service description AN4018 12/23 docid022544 rev 3 4.2.3 get mac address void dl_addressget(u8* address) description: this service is used to read the current mac address. input parameters: ? address: pointer to the address (6-byte array). output parameters: none. return value: none. 4.3 data link services these services provide the functions to send, to receive messages and to manage the network joining. 4.3.1 allow join request s8 dl_allowjoinrequest(u8* daddress, u8* data, u8 dlen) description: this service is used by the application layer to perform an ?allow join request? to another node. input parameters: ? daddress: pointer to destination node mac address ? data: pointer to data collection to send to the node (free application data) ? dlen: length of data, number of bytes. output parameters: none. return value: data link error code value. 4.3.2 join indication u8* dl_joinindication(void) description: this service reports to the application layer if a join indication occurs. docid022544 rev 3 13/23 AN4018 service description input parameters: none. output parameters: none. return value: join indication identifier. 4.3.3 data request s8 dl_datarequest(u8* daddress, u8 dlen, u8* data) description: this service is used by the application layer to send a data collection to another node. input parameters: ? daddress: pointer to destination node mac address ? data: pointer to data collection to send to the node ? dlen: length of data, number of bytes. output parameters: none. return value: data link error code value. 4.3.4 data indication u8* dl_dataindication(u8* saddress, u8* dlen, u8* diparam) description: this service reports to the application layer if a data indication occurs. input parameters: none. output parameters: ? saddress: pointer to source node mac address ? dlen: length of data payload, number of bytes ? diparam: data indication parameters, 4 bytes (see the um0932 user manual). return value: pointer to data collection (payload). service description AN4018 14/23 docid022544 rev 3 4.4 data link security services these services provide the functions to send and receive messages with security features. the security data management is performed by using the st7580 on-chip 128-bit aes encryption hw block. for further information about the use of security service, see appendix d . 4.4.1 security data request s8 dl_ss_datarequest(u8* daddress, u8 dlen, u8* data) description: this service is used by application layer to send a data collection in security mode to another node. input parameters: ? daddress: pointer to destination node mac address ? data: pointer to data collection to send to the node ? dlen: length of data, number of bytes. output parameters: none. return value: data link error code value. 4.4.2 security data indication u8* dl_ss_dataindication(u8* saddress, u8* dlen, u8* diparam) description: this service reports to application layer if a security data indication occurs. input parameters: none. output parameters: ? saddress: pointer to source node mac address ? dlen: length of data payload, number of bytes ? diparam: data indication parameters, 4 bytes (see the um0932 user manual). return value: pointer to data collection (payload). docid022544 rev 3 15/23 AN4018 service description 4.5 mib management services these services provide functions to read, write or erase the mib (management information base) of the power line modem, see table 1 for details. for more information about the mib services and their management, please see the st7580 datasheet. 4.5.1 mib reading s8 dl_mib_readrequest (mib_index_obj_t mibindex, u8* data) description: this service is used by the application layer to read the mib object information. input parameters: ? mibindex: index of mib object, (see tab le 1 ). output parameters: ? data: pointer to mib data object (the length depends on the object, see the st7580 datasheet). return value: status or error value, (see ta ble 2 ). 4.5.2 mib writing s8 dl_mib_writerequest (mib_index_obj_t mibindex, u8* data) description: this service is used by the application layer to write new data to the mib object. it is possible to use this service only for the mib object with the following index: 0x00, 0x01, 0x02, 0x09. input parameters: ? mibindex: index of mib object (see table 1 ) ? data: pointer to mib data object (the length depends on the object, see the st7580 datasheet). output parameters: none. return value: status or error value, (see ta ble 2 ). 4.5.3 mib erasing s8 dl_mib_erase (mib_index_obj_t mibindex) service description AN4018 16/23 docid022544 rev 3 description: this service is used by the application layer to erase the mib object information. it is possible to use this service only for the mib object with the following index: 0x06, 0x07, 0x08. input parameters: ? mibindex: index of mib object, (see tab le 1 ). output parameters: none. return value: status or error value, (see ta ble 2 ). 4.5.4 mib parameters table 1. mib object index index name length (byte) r/w/e 00h modem configuration 1 r/w 01h phy configuration 14 r/w 02h ss key 16 r/w 03h reserved 1 r 04h last data indication 4 r 05h last tx confirm 5 r 06h phy_data 10 r/e 07h dl_data 12 r/e 08h ss_data 10 r/e 09h host interface timeout 3 r/w 0ah firmware version 4 r table 2. service return values value description dl_busy data link is busy with another process, the service can?t be performed dl_wait wait state, the service is in execution phase dl_timeout this is an error timeout, the service failed due to timeout dl_error generic error. service failed dl_ok service processed correctly docid022544 rev 3 17/23 AN4018 join procedure appendix a join procedure figure 5 shows the join procedure diagram. figure 5. join procedure diagram the actions performed by the master are: ? sends the allow join ? waits for the join acknowledge ? when the join request arrives, it sends a join ack and marks the module as ?joined?. at the same time the actions performed by the slave are: ? waits for the allow join request ? when an allow join request arrives, sends a join request ? waits for the jack ? when the jack arrives, the module is able to receive a data. the message sequences are described in figure 6 : figure 6. message sequences the join procedure is mandatory for nodes configured as slave; if the joined procedure doesn't perform correctly, a slave node is not able to communicate with the master. $ 0 y 0 d v w h u 6 o d y h $ s s o l f d w l r q / d \ h u $ s s o l f d w l r q / d \ h u ' d w d / l q n ' d w d / l q n ' / b $ o o r z - r l q 5 h t x h v w $ o o r z - r l q l q g l f d w l r q - $ & |